var countdown=60;
var djsno=true;
var mreg_timr;
function settime(val) { 
	if (countdown == 0) {
		val.removeClass("mreg_disabled").html("免费获取验证码");
		djsno=true;
	} else {
		val.addClass("mreg_disabled").html("重新发送(" + countdown + ")");
		countdown--;
		djsno=false;
	} 
	if(!djsno){mreg_timr=setTimeout(function(){settime(val)},1000);}
}
function stopTime(val){
	//djsno=true;
	countdown = 0;
	//val.removeClass("mreg_disabled").html("免费获取验证码");
}
$("#btn_msend_code").on("click",function(){
	if(djsno){
		var btn=$(this);
		var mobile=$("#mobile").val();
		//开始发送
		$.getJSON(lodo_web_path+"Plugins/alidayuyz/sendCode.asp?mobile="+mobile,function(data){
			if(data.errno){stopTime(btn);alert(data.msg);return false;}
			if(data.ok){
				countdown = 60;
				settime(btn);
				alert("注册验证码已成功发送到您填写的手机上了，请查收！");
				return false;
			}
			if(data.gotono){location.href=data.gotourl;}
			return false;
		});
	}
});
$("#btn_mregsave").on("click",function(){
	var options={
		url:lodo_web_path+"Plugins/alidayuyz/mobilecheck.asp",
		dataType:"json",
		success:function(data){
			if(data.errno){alert(data.msg);}
			if(data.gotono){location.href=data.gotourl;}
		}
	};
	$("#mregform").ajaxSubmit(options);
});